package com.suning.sawp.in.controller;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.suning.sawp.constants.ErrorCodeConstants;
import com.suning.sawp.constants.LoggerConstants;
import com.suning.sawp.dto.common.ReturnMsg;
import com.suning.sawp.dto.precharge.CommonRtn;
import com.suning.sawp.intf.servicenum.ServiceNumService;
import com.suning.vgs.follow.remote.intf.ServiceNumRemoteService;
import com.suning.vgs.follow.remote.store.ServiceNumDto;

/**
 * 
 * 〈一句话功能简述〉<br>
 * 〈功能详细描述〉
 * 
 * @author Wuxiao
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Controller
@RequestMapping("/adminPage/serviceNum")
public class ServiceNumController extends DjBaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(LoggerConstants.SAWP_SERVICE);
    
    @Resource
    ServiceNumService serviceNumService;
    
    @Resource
    ServiceNumRemoteService serviceNumRemoteService;
    
    /**
     * 
     * 功能描述:查询服务号信息 <br>
     * 〈功能详细描述〉
     * 
     * @param serviceNumId
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/queryNumInfo.do")
    public MyGsonView queryServiceNum(String serviceNumId) {
        ReturnMsg<List<ServiceNumDto>> ret = new ReturnMsg<List<ServiceNumDto>>();
        try {
            ret = serviceNumService.queryServiceNumInfo(serviceNumId);
        } catch (Exception e) {
            LOGGER.error("query serviceNumInfo exception",e);
            ret.setRetFlag(ReturnMsg.FAIL);
            ret.setError(ErrorCodeConstants.SERVICE_NUM_ERR_999,
                    ErrorCodeConstants.SERVICE_NUM_ERR_MAP
                            .get(ErrorCodeConstants.SERVICE_NUM_ERR_999));
        }
        return setGsonView(ret);
    }

    /**
     * 
     * 功能描述: 保存服务号信息<br>
     * 〈功能详细描述〉
     * 
     * @param serviceNumId
     * @param serviceNumName
     * @param systemIds
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/save.do")
    public MyGsonView saveServiceNum(String serviceNumId, String serviceNumName, String systemIds) {
        ReturnMsg<CommonRtn> ret = new ReturnMsg<CommonRtn>();
        try {
            ret = serviceNumService.saveServiceNum(serviceNumId, serviceNumName, systemIds);
        } catch (Exception e) {
            LOGGER.error("save serviceNumInfo exception",e);
            ret.setRetFlag(ReturnMsg.FAIL);
            ret.setError(ErrorCodeConstants.SERVICE_NUM_ERR_999,
                    ErrorCodeConstants.SERVICE_NUM_ERR_MAP
                    .get(ErrorCodeConstants.SERVICE_NUM_ERR_999));
        }
        return setGsonView(ret);
    }
    
}
